// 基础设施-护理服务管理

import r from '@/utils/request';
import type { ResponseType, ListParams, ListResponseType } from '../types';

enum API {
    nursingServiceList = '/nursingService/list', // 护理服务列表
    nursingServiceDelete = '/nursingService/delete', // 删除护理服务
    nursingServiceDeleteAll = '/nursingService/deleteAll', // 批量删除护理服务
    nursingServiceAdd = '/nursingService/add', // 护理服务添加
    nursingServiceUpdate = '/nursingService/update', // 护理服务修改
}


// 护理服务列表返回值
export type nursingServiceListRes = {
    id: number;
    companyId: number;
    name: string;
    content: string;
}
// 护理服务列表接口
export function nursingServiceListAPI(params: ListParams): Promise<ListResponseType<nursingServiceListRes>> {
    return r.get(API.nursingServiceList, params)
}

// 删除护理服务接口
export function nursingServiceDeleteAPI(id: number): Promise<ResponseType<string>> {
    return r.delete(API.nursingServiceDelete + '/' + id)
}


// 批量删除护理服务接口
export function nursingServiceDeleteAllAPI(ids: number[]): Promise<ResponseType<string>> {
    return r.post(API.nursingServiceDeleteAll, ids)
}

// 护理服务添加返回值
type nursingServiceAddRes = ResponseType<{
    id?: number;
    companyId?: number;
    name: string;
    content: string;
}>

// 护理服务添加接口
export function nursingServiceAddAPI(params:nursingServiceUpdateParams): Promise<nursingServiceAddRes> {
    return r.post(API.nursingServiceAdd,params)
}

// 护理服务修改参数
interface nursingServiceUpdateParams {
    id?: number
    name: string
    content: string
}

// 护理服务修改返回值
type nursingServiceUpdateRes = ResponseType<{
    id: number;
    companyId: number;
    name: string;
    content: string;
}>

// 护理服务修改接口
export function nursingServiceUpdateAPI(params: nursingServiceUpdateParams): Promise<nursingServiceUpdateRes> {
    return r.put(API.nursingServiceUpdate, params)
}
